package o;

import android.app.PendingIntent;
import android.text.TextUtils;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appmarket.framework.coreservice.Status;
import com.huawei.appmarket.service.externalapi.secureactivity.SecureProxyActivity;
import com.huawei.appmarket.service.externalservice.distribution.download.response.TaskOperationResponse;
import com.huawei.hms.support.api.entity.pay.HwPayConstant;
import java.util.LinkedHashMap;

public class dzg {
    public static Status ˋ(String str, String str2, String str3, TaskOperationResponse taskOperationResponse, int i) {
        Status status = new Status();
        if (TextUtils.isEmpty(str2) || TextUtils.isEmpty(str3) || TextUtils.isEmpty(str)) {
            status.ˋ(9);
        } else {
            status.ˋ(0);
            if (!ˋ(str, str2, str3, i)) {
                taskOperationResponse.ˏ(-1);
            } else if (i == 4) {
                status.ˋ(6);
                PendingIntent ˋ = ˋ(str, str3);
                if (ˋ != null) {
                    status.ˊ(ˋ);
                }
            }
        }
        return status;
    }

    private static PendingIntent ˋ(String str, String str2) {
        SessionDownloadTask ˋ = dvt.ˏ().ˋ(str);
        if (ˋ == null) {
            return null;
        }
        return SecureProxyActivity.ˎ(ContentManager.getInstant().getContext(), str2, dxi.ॱ(str, ˋ.ˊˋ(), ˋ.ʼॱ(), null, true));
    }

    private static boolean ˋ(String str, String str2, String str3, int i) {
        SessionDownloadTask ˊ = dvt.ˏ().ˊ(str, 8);
        if (ˊ == null) {
            ˊ = dvt.ˏ().ˊ(str, 11);
        }
        if (ˊ == null || (!str3.equals(ˊ.ॱˎ("mediaPkg")) && !str2.equals(ˊ.ॱˎ("callerPkg")))) {
            return false;
        }
        ˋ(ˊ, i);
        return true;
    }

    private static void ˋ(SessionDownloadTask sessionDownloadTask, int i) {
        switch (i) {
            case 1:
                ˎ(sessionDownloadTask);
                sessionDownloadTask.ˋॱ(8);
                dvt.ˏ().ˊ(sessionDownloadTask.ʾ());
                return;
            case 2:
                ˊ(sessionDownloadTask);
                sessionDownloadTask.ˋॱ(8);
                dvt.ˏ().ˎ(sessionDownloadTask, 1, false);
                return;
            case 3:
                ˋ(sessionDownloadTask);
                dvt.ˏ().ॱ(sessionDownloadTask.ʾ());
                return;
            case 4:
                ˎ(sessionDownloadTask);
                return;
            default:
                return;
        }
    }

    private static void ˊ(SessionDownloadTask sessionDownloadTask) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("pkgName", sessionDownloadTask.ˊˊ());
        linkedHashMap.put("detailId", sessionDownloadTask.ॱˊ());
        linkedHashMap.put("advPlatform", sessionDownloadTask.ॱˎ("advPlatform"));
        linkedHashMap.put("mediaPkg", sessionDownloadTask.ॱˎ("mediaPkg"));
        linkedHashMap.put("advInfo", sessionDownloadTask.ॱˎ("advInfo"));
        linkedHashMap.put("referrer", sessionDownloadTask.ॱˎ("referrer"));
        linkedHashMap.put("callWay", String.valueOf(1));
        linkedHashMap.put(HwPayConstant.KEY_COUNTRY, eqp.ॱ());
        dgh.ˋ("380102", linkedHashMap);
    }

    private static void ˋ(SessionDownloadTask sessionDownloadTask) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("pkgName", sessionDownloadTask.ˊˊ());
        linkedHashMap.put("detailId", sessionDownloadTask.ॱˊ());
        linkedHashMap.put("advPlatform", sessionDownloadTask.ॱˎ("advPlatform"));
        linkedHashMap.put("mediaPkg", sessionDownloadTask.ॱˎ("mediaPkg"));
        linkedHashMap.put("advInfo", sessionDownloadTask.ॱˎ("advInfo"));
        linkedHashMap.put("referrer", sessionDownloadTask.ॱˎ("referrer"));
        linkedHashMap.put("callWay", String.valueOf(1));
        linkedHashMap.put(HwPayConstant.KEY_COUNTRY, eqp.ॱ());
        dgh.ˋ("380103", linkedHashMap);
    }

    private static void ˎ(SessionDownloadTask sessionDownloadTask) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("pkgName", sessionDownloadTask.ˊˊ());
        dgh.ˋ("380104", linkedHashMap);
    }

    public static void ˏ(dxn o_dxn) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("pkgName", o_dxn.ʼ());
        linkedHashMap.put("mediaPkg", o_dxn.ˏ());
        linkedHashMap.put("advInfo", o_dxn.ᐝ());
        linkedHashMap.put("downloadParams", o_dxn.ʽ());
        linkedHashMap.put("advPlatform", String.valueOf(o_dxn.ˎ()));
        linkedHashMap.put("referrer", o_dxn.ʻ());
        linkedHashMap.put(HwPayConstant.KEY_COUNTRY, eqp.ॱ());
        linkedHashMap.put("callWay", String.valueOf(1));
        dgh.ˋ("380101", linkedHashMap);
    }
}
